<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>去保养</title>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta name="keywords" content="汽车保养,汽车配件,汽车维修,养车无忧,养车,4S店品质,氦修驿站,丰田保养" />
    <meta name="description" content="100%正品配件,4S店一半价格,先行赔付,闪电送达!线上购买配件,线下提供安装.上万用户的最佳选择!去掉中间环节,直接从源头采购配件!" />
	<link rel="stylesheet" type="text/css" href="{:C('WEB_URL')}Public/css/base.css">
    <link rel="stylesheet" type="text/css" href="{:C('WEB_URL')}Public/mobile/css/master.css">
</head>
<body>
    <header>
        <a href="tel:4006730088" class="tel iconfont">&#xe60c;</a>
        <a href="javascript:void(0)" class="menu iconfont" onclick="home.showMenu()">&#xe602;</a>
        <img src="{:C('WEB_URL')}Public/mobile/images/logo.png" id="logo">
    </header>

    <div class="wrap" id="login">
        <ul>
            <li>
                <input type="tel" name="phone" placeholder="请输入您的手机号" />
            </li>
            <li>
                <input type="password" name="code" placeholder="6位短信验证码" />
                <a href="javascript:void(0)" class="getCode" id="J_getCode">获取验证码</a>
            </li>
        </ul>
        <a href="javascript:void(0)" class="iconfont" id="btnSubmit">提交</a>
    </div>
    <include file="Public/mobileHome" />

    <script>

        ;
        (function(){
            $("#J_getCode").on("click",function(){

                var _t = $(this);

                if (_t.hasClass("getCodeGray")) {
                    return false;
                }

                var phone=$("input[name='phone']").val();
                if(!/^(13|15|18|14|17)[0-9]{9}$/.test(phone)){
                    showMsgTip("您的手机号有误");
                    return false;

                }

                _t.addClass("getCodeGray");

                $.ajax({
                    url:"{:C('WEB_URL')}mobile/getCode.html",
                    type:"POST",
                    data:{"username":phone},
                    datType:"JSON",
                    success:function(res){
                        if(res.status==1){
                            setCookie("codeMin",60);
                            countDown(_t);
                        }else{
                            _t.removeClass("getCodeGray");
                            alert(res['info']);
                        }
                    }
                })
            })

            $("#btnSubmit").on("click",function(){
                var _t = $(this);
                

                var phone=$("input[name='phone']").val(),
                    code=$("input[name='code']").val().replace(/\D/g,"");
                if(!/^(13|15|18|14|17)[0-9]{9}$/.test(phone)){
                    showMsgTip("您的手机号有误");
                    return false;
                }else if(code.length!=6){
                    showMsgTip("短信验证码有误");
                    return false;
                }

                $.ajax({
                    url:"{:C('WEB_URL')}mobile/valCode.html",
                    type:"POST",
                    data:{"phone":phone,"code":code},
                    datType:"JSON",
                    success:function(res){
                        if(res.status==1){
                            var toPage=getQuery("back");
                            if(toPage!=null){
                                window.location.href="{:C('WEB_URL')}mobile/my"+toPage;
                            }
                            
                        }else{
                            showMsgTip(res.info);
                            return false;
                        }
                    }
                })
            })


            getCodeStatus();
            function getCodeStatus(){
                var min=getCookie("codeMin");
                if(min>0){
                    $("#J_getCode").addClass("getCodeGray");
                    countDown($("#J_getCode"));
                }
            }



            //验证码倒计时
            function countDown(_t) {

                min=getCookie("codeMin")*1-1;

                if (min == 0) {
                    _t.html("获取验证码");
                    _t.removeClass("getCodeGray");
                } else {
                    _t.html(min+"秒后重新获取");
                    setCookie("codeMin",min--);
                    setTimeout(function() {
                        countDown(_t);
                    },1000)
                }
            }

            $("#msgTip").on("click",function(){
                $("#msgTip").hide();
            })

        })()


    </script>
    

</body>
</html>